﻿using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Framework.Reflection.Controller;
using Pixysoft.Framework.Verifications;

namespace Pixysoft.Framework.Reflection.Core
{
    class DummyPropertyInfo : DummyMemberInfo, IDummyPropertyInfo
    {
        bool canRead = false;
        bool canWrite = false;
        IDummyType _value;

        public bool CanRead
        {
            get { return canRead; }
            set { canRead = value; }
        }

        public bool CanWrite
        {
            get { return canWrite; }
            set { canWrite = value; }
        }

        [PropertyType]
        public IDummyType PropertyType
        {
            get { return _value; }
            set
            {
                //输入可能为null 在数据模式中，会出现null数据值 代表空

                LoggerHelper.Log("-> DummyPropertyInfo.PropertyType = {0};", value);
                this._value = value;
            }
        }

        public override string ToString()
        {
            return this.Name;
        }

        public override void Dispose()
        {
            base.Dispose();
            this._value = null;
        }

        public override bool Verify()
        {
            base.Verify();

            foreach (IDummyType att in GetCustomAttributes())
                att.Verify();

            return true;
        }

        internal class PropertyTypeAttribute : Attribute { }
    }
}
